package org.game.ddd.client.bean;

import org.game.ddd.common.model.CellModel;
import org.game.ddd.client.view.CellView;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@Component
public class CellBean {
    private Long id = 0L;

    public CellModel cellModel() {
        CellModel cellModel = new CellModel();
        cellModel.setCellId(id++);
        cellModel.setWidth(100);
        cellModel.setHeight(100);
        cellModel.setX(new Random().nextInt(1000) - 100);
        cellModel.setY(new Random().nextInt(1000) - 100);
        return cellModel;
    }

    @Bean
    public List<CellModel> cellModelList() {
        List<CellModel> cellModelList = new ArrayList<>();
        cellModelList.add(cellModel());
        cellModelList.add(cellModel());
        return cellModelList;
    }

    @Bean
    public List<CellView> cellViewList() {
        List<CellView> cellViewList = new ArrayList<>();
        cellViewList.add(new CellView(cellModel()));
        cellViewList.add(new CellView(cellModel()));
        cellViewList.add(new CellView(cellModel()));
        return cellViewList;
    }
}
